#pragma once

#pragma region Processor Directives

#include <d3d9.h>
#include <d3dx9.h>
#include <time.h>
#include <dshow.h>
#include "Menu.h"
#include "DXTimer.h"
#include "DirectInput.h"

#pragma endregion

#pragma region Assets

#include "Luigi.h"
#include "Enemy.h"

#pragma endregion

#pragma region Linking Libraries

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "dxguid.lib")

#pragma endregion

#pragma region Macros

#define SAFE_RELEASE(x) if(x) {x->Release(); x = 0;}

#pragma endregion

class PaperLuigiFramework
{
private:
	#pragma region Window variables

	HWND m_hWnd;//handle to the window
	int m_nWidth;//window width
	int m_nHeight;//window height
	bool m_bVSync;//bool for vertical sync

	#pragma endregion

	#pragma region Camera variables

	//The three rows that are needed to make the camera's matrix as well as the matrix to store it
	//the matrix for projection and variables for moving the camera
	D3DXVECTOR3 m_RightVec;
	D3DXVECTOR3 m_EyePos;
	D3DXVECTOR3 m_LookAt;
	D3DXVECTOR3 m_UpVec;
	D3DXMATRIX m_ViewMat;
	D3DXMATRIX m_ProjMat;
	float m_CameraSpeed;
	float m_CameraPitch;
	float m_CameraYAngle;

	#pragma endregion

	#pragma region Transformation Matrices

	D3DXMATRIX worldMat;//world matrix used for setting the transform
	D3DXMATRIX worldInverseTransposeMat;//world inverse transpose used in shader
	D3DXMATRIX rotMat;//rotation matrix
	D3DXMATRIX scaMat;//scaling matrix
	D3DXMATRIX transMat;//translation matrix

	#pragma endregion

	#pragma region Materials and Light

	//Materials and light
	D3DLIGHT9 m_Light;
	D3DMATERIAL9 m_MaterialNorm;
	D3DXVECTOR3 m_Attenuation012;

	#pragma endregion

	#pragma region DirectX COM Objects and variables

	IDirect3D9* m_pD3DObject;// This is the object that we will be using to create the device to render
	IDirect3DDevice9* m_pD3DDevice;//This is the device that will render most of the graphic
	ID3DXFont* m_Font;//font object
	D3DPRESENT_PARAMETERS m_D3Dpp; //Presentation Parameters
	D3DCAPS9 m_D3Dcaps;//This is used to find the capabilities of the hardware to see if it can handle new features.
	DWORD m_devBehaviorFlags;//gets the behaviorflags used for vertex processing

	#pragma endregion

	#pragma region Timer, Menu, Input

	DXTimer timer;
	float m_Fps;//frames per second variable
	float m_MillSpf;//milliseconds per frame variable
	float dt;
	Menu menu;
	States state;
	States currState;
	DirectInput input;
	bool keyDown[256];
	ID3DXSprite* m_Sprite;
	//IDirect3DTexture9* m_Player;

	#pragma endregion

	#pragma region Characters

	Luigi* luigi; // Holds Luigi's information
	Enemy* enemy; // temporary variable to hold temporary enemy's information. /* Delete Later! */

	#pragma endregion

	#pragma region Walls & Stuff

	ID3DXMesh* m_BoxMesh;

	#pragma endregion

public:

	#pragma region Constructor/Destructor

	PaperLuigiFramework(void);
	~PaperLuigiFramework(void);

	#pragma endregion

	#pragma region Initialization Methods

	void Initialize(HWND hWnd, HINSTANCE hInst, bool bWindowed);
	void DetermineCaps();
	void createTextures();
	void createMaterials();
	void createViewMat();
	void createProjMat();

	#pragma endregion

	#pragma region Visualization Methods

	void Update();
	void testInput(float dt);
	void Render();

	#pragma endregion

	#pragma region Sizing Window Methods

	void screenResize();
	void switchingFullScreen(bool enable);

	#pragma endregion

	#pragma region lostDevice Methods

	bool lostDevice();
	void onLostDevice();
	void onLostEffect();
	void onResetDevice();
	void onResetEffect();

	#pragma endregion

	#pragma region Destruction Methods

	void shutdownMeshes();
	void releaseTextures();
	void Shutdown();

	#pragma endregion
};
